﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace jaysJourney_v01.Utils.Output
{
    class Message
    {
        /**
         * MEMBER VARIABLES
         * */

        // From Parent

        private int maxLifeTime; // Millisecs
        private int lifeTime; // Millisecs

        // Common

        private List<String> message;
        private bool isError;
        private float alpha;

        // Message

        private int messageHeight;

        /**
         * METHODS
         * */

        // Constructor

        public Message(int lifeTime, int messageHeight, List<String> message, bool isError)
        {
            // setter
            this.maxLifeTime = lifeTime;
            this.lifeTime = lifeTime;
            this.messageHeight = messageHeight;
            this.message = message;
            this.isError = isError;

            this.alpha = 1f;
        }

        // update

        public void update(GameTime gameTime)
        {
            // Decrease Lifespan
            this.lifeTime -= gameTime.ElapsedGameTime.Milliseconds;

            // Decrease Alpha when Lifespan is lower than 1/3
            if (this.lifeTime < this.maxLifeTime / 5) alpha -= ((float)gameTime.ElapsedGameTime.Milliseconds / 1000f);
        }

        // get lifeSpan

        public int getLifeSpan()
        {
            return this.lifeTime;
        }

        // get msgHeight

        public int getMsgHeight()
        {
            return this.messageHeight;
        }

        // get msg

        public List<String> getMessage()
        {
            return this.message;
        }

        // get error

        public bool isErrMsg()
        {
            return this.isError;
        }

        // get alpha

        public float getAlpha()
        {
            return this.alpha;
        }
    }
}
